package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    @PostMapping("/submit")
    public R<String> stringR(@RequestBody Orders orders){
        ordersService.submit(orders);
        return R.success("下单成功");
    }
    @GetMapping("/userPage")
    public R<Page> select(Integer page,Integer pageSize){
        Page<Orders> page1=new Page<>(page,pageSize);
        Page<Orders> page2 = ordersService.page(page1);
        return R.success(page2);
    }
//    订单明细
    @GetMapping("/page")
    public R<Page<Orders>> pageR(Integer page,Integer pageSize){
        Page<Orders> page1=new Page<>(page,pageSize);
        Page<Orders> page2 = ordersService.page(page1);
        return R.success(page2);
    }
}
